package com.hx.er.action.common;

import java.io.ByteArrayInputStream;

import com.hx.er.action.base.ErBaseAction;
import com.hx.er.common.system.Constants;
import com.hx.er.common.system.ErProperties;
import com.hx.er.common.util.SecurityCodeUtil;

public class ValidateCodeAction extends ErBaseAction {

	private static final long serialVersionUID = 7262416553973284093L;

	// 图片流
	private ByteArrayInputStream imageStream;

	public String init() {
		String securityCode = SecurityCodeUtil.getSecurityCode(Integer.parseInt(ErProperties.getProperty(Constants.PROPERTY_SECURITY_CODE_LENGTH)));

		super.request.getSession().setAttribute(Constants.SESSION_SECURITY_CODE, securityCode);
		this.imageStream = SecurityCodeUtil.getImageAsInputStream(securityCode);

		return SUCCESS;
	}

	public ByteArrayInputStream getImageStream() {
		return this.imageStream;
	}

	public void setImageStream(ByteArrayInputStream imageStream) {
		this.imageStream = imageStream;
	}
}
